from django.contrib.auth.forms import UserCreationForm, UserChangeForm
from django.core.exceptions import ValidationError

from . import models


class SiteUserCreationForm(UserCreationForm):

    class Meta:
        model = models.SiteUser
        fields = ('email', 'user_status',)


    def clean_is_confirmed_by_administrator(self):

        if self.cleaned_data['user_status'] == 'manager': return False
        else: return True


class SiteUserChangeForm(UserChangeForm):

    class Meta:
        model = models.SiteUser
        fields = ('email', 'user_status')


    def clean_is_confirmed_by_administrator(self):

        if self.cleaned_data['user_status'] == 'administrator': return True
        else: return False
